<?php

class CountersWidget extends CWidget
{
    public function run()
    {
    	$criteria = new CDbCriteria(array('condition' => 'doc_type=1', 'join' => 'LEFT JOIN {{documents}} d ON (t.doc_id=d.id)'));
		$type1 = UserDocuments::model()->count($criteria);
		$criteria = new CDbCriteria(array('condition' => 'doc_type=2', 'join' => 'LEFT JOIN {{documents}} d ON (t.doc_id=d.id)'));
		$type2 = UserDocuments::model()->count($criteria);
    	
        //подключаем JS скрипт
        Yii::app()->clientScript->registerScriptFile('http://ulogin.ru/js/ulogin.js', CClientScript::POS_HEAD);
        $this->render('countersWidget', array(
        		'complaint' => $type1,
        		'lawsuit' => $type2,
        		));
    }

}
